package net.flyinggroup.mapstruct.mapper;

import net.flyinggroup.mapstruct.anno.PoundToKilogramMapper;
import net.flyinggroup.mapstruct.model.UserBodyImperialValueDTO;
import net.flyinggroup.mapstruct.model.UserBodyValues;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

@Mapper
public interface UserBodyValuesMapper {
    UserBodyValuesMapper INSTANCE = Mappers.getMapper(UserBodyValuesMapper.class);

    @Named("inchToCentimeter")
    static double inchToCentimeter(int inch) {
        return inch * 2.54;
    }

    @PoundToKilogramMapper
    static double poundToKilogram(int pound) {
        return pound * 0.4535;
    }

    @Mapping(source = "inch", target = "centimeter", qualifiedByName = "inchToCentimeter")
    @Mapping(source = "pound", target = "kilogram", qualifiedBy = PoundToKilogramMapper.class)
    UserBodyValues toUserBodyValues(UserBodyImperialValueDTO dto);
}
